package h0813;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * @author 不知名帅哥
 * @version 1.0
 * @description 机器人走迷宫
 * @date 2024/8/12 23:39
 */
public class RobotWalkMaze {
    static int[][] arr;
    static int m; //行数
    static int n; //列数
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
         m = sc.nextInt();
         n = sc.nextInt();
        arr = new int[m][n];
        //墙壁个数
        int N = sc.nextInt();
        for (int i = 0; i < N; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            //等于1为墙壁
            arr[a][b] = 1;
        }
        arr[m-1][n-1]=2; //将终点置为2

        getResult();
    }

    private static void getResult() {
        //深度优先搜索
        dfs(0,0);

        int trap=0; //陷阱数量
        int unreach=0; //不可达点数量
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (arr[i][j]==0) unreach++;
                else if (arr[i][j]==-1) trap++;
            }
        }
        System.out.println(trap+" "+unreach);
    }

    //TODO DFS
    private static boolean dfs(int cx, int cy) {
        if (cx>=m||cy>=n){
            return false;
        }
        if (arr[cx][cy]==1) return false;
        if (arr[cx][cy]==-1) return false;
        if (arr[cx][cy]==2) return true;
        if (arr[cx][cy]==0){
            boolean east=dfs(cx+1,cy);
            boolean north=dfs(cx,cy+1);

            if (east||north){ //如果向北和向东可达，则当前点可达，将值设为2
                arr[cx][cy]=2;
            }else {
                arr[cx][cy]=-1; //否则，不可达。设置为陷阱-1
            }
        }
        return arr[cx][cy]==2;
    }
}
